package com.ruoyi.teacher.course.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.teacher.course.domain.Excellcourse;
import com.ruoyi.teacher.course.mapper.ExcellcourseMapper;
import com.ruoyi.teacher.course.service.IExcellcourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 精品课程Service业务层处理
 *
 * @author duanxinli
 * @date 2023-11-07
 */
@Service
public class ExcellcourseServiceImpl implements IExcellcourseService {
    @Autowired
    private ExcellcourseMapper excellcourseMapper;

    /**
     * 查询精品课程
     *
     * @param id 精品课程主键
     * @return 精品课程
     */
    @Override
    public Excellcourse selectExcellcourseById(String id) {
        return excellcourseMapper.selectExcellcourseById(id);
    }

    /**
     * 查询精品课程列表
     *
     * @param excellcourse 精品课程
     * @return 精品课程
     */
    @Override
    public List<Excellcourse> selectExcellcourseList(Excellcourse excellcourse) {
        return excellcourseMapper.selectExcellcourseList(excellcourse);
    }

    /**
     * 新增精品课程
     *
     * @param excellcourse 精品课程
     * @return 结果
     */
    @Override
    public int insertExcellcourse(Excellcourse excellcourse) {
        excellcourse.setId(IdUtils.fastUUID());
        if (excellcourse.getCreateDate()==null){
            excellcourse.setCreateDate(DateUtils.getNowDate());
        }
        String username = SecurityUtils.getUsername();
        excellcourse.setCreateBy(username);
        excellcourse.setSort(0L);
        return excellcourseMapper.insertExcellcourse(excellcourse);
    }

    /**
     * 修改精品课程
     *
     * @param excellcourse 精品课程
     * @return 结果
     */
    @Override
    public int updateExcellcourse(Excellcourse excellcourse) {
        return excellcourseMapper.updateExcellcourse(excellcourse);
    }

    /**
     * 批量删除精品课程
     *
     * @param ids 需要删除的精品课程主键
     * @return 结果
     */
    @Override
    public int deleteExcellcourseByIds(String[] ids) {
        return excellcourseMapper.deleteExcellcourseByIds(ids);
    }

    /**
     * 删除精品课程信息
     *
     * @param id 精品课程主键
     * @return 结果
     */
    @Override
    public int deleteExcellcourseById(String id) {
        return excellcourseMapper.deleteExcellcourseById(id);
    }
}
